package cn.youyeku.customizeview;

import android.content.Context;
import android.content.res.TypedArray;
import android.databinding.DataBindingUtil;
import android.graphics.Canvas;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import cn.youyeku.customizeview.databinding.ViewSettingBinding;

public class SettingText extends LinearLayout {
   public ViewSettingBinding binding;
    public SettingText(Context context) {
        super(context);
    }

    /**
     * 构造方法引入布局
     *
     * @param context
     * @param attrs
     */
    public SettingText(final Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);

        //第一个参数是加载的id 第二个参数是加载好的布局添加一个父布局 传入this  传null引发错误 引发什么错误稍后测试
//        View view = LayoutInflater.from(context).inflate(R.layout.view_setting, this);
         //false 是什么

        //If false, parent is only used to create the correct subclass of LayoutParams for the root view in the XML.
        //如果是ture 会在父其他视图中创建 这里必须是true
         binding = DataBindingUtil.inflate(LayoutInflater.from(context),R.layout.view_setting,this,true);



        TypedArray typedArray = context.obtainStyledAttributes(attrs,R.styleable.setting);
        String title=typedArray.getString(R.styleable.setting_title);
        String value=typedArray.getString(R.styleable.setting_value);

        Log.w("----",title+" "+value);
        binding.settingInfo.setText(title);
        binding.settingValues.setText(value);


        //重新使用
        typedArray.recycle();
    }
    private void init(Context context) {
//        View.inflate(context, R.layout.view_setting, this);
//        tv = (TextView) this.findViewById(R.id.setting_info);
//        tv2 = (TextView) this.findViewById(R.id.setting_values);
//


    }



}
